// JavaScript Document
/* 

1、放大显示层
2、缩小隐藏层

onclick="ShowPayDiv('要弹出的层的ID','弹出层的背景层id','弹出层的宽','弹出层的高','遮蔽层的透明度','弹出层的速度','遮蔽层的背景色','弹出层的背景色','所处理表单的索引','弹出层中需要显示的层ID');" 
onclick="ShowPayDiv('div1ID','div2ID','500','300','50','50','#000000','White',0,'payDiv1');"
关闭时在要弹出的组建中加入事件onclick="Close()";即可
 */
var dfShowDiv="showdiv";//弹出层(主层)的默认ID

var dfShowBgDiv="showbgdiv";//弹出层的背景层默认ID

var dfShowContentDiv="showcontentdiv";//弹出层中需要显示内容的层的默认ID

var dfShowDivWidth="500";//弹出层(主层)默认宽度

var dfShowDivHeight="400";//弹出层(主层)默认高度

var dfShowBgDivAlpha="50";//弹出层的背景层的默认透明度/百分比

var dfShowDivSpeed="10";//弹出\关闭层的速度，值越小速度越快

var dfShowBgDivBgColor="none";//弹出层的背景层的默认背景色

var dfShowDivBgColor="#999999";//弹出层的默认背景色

var dfFormIndex=1;//表单默认索引

var dfCoverDiv="coverdiv";//被覆盖的层ID
var iWidth = document.documentElement.offsetWidth;//浏览器宽度(滚动条+clientwidth+边框）
var iHeight =  document.documentElement.scrollHeight;
//var iHeight = document.body.clientHeight;
/* 无参函数 */
function showDfDiv(){
	//隐藏覆盖层
	document.getElementById(dfCoverDiv).style.visibility = "hidden";
	
	//弹出背景层
	showBgDiv();
	
	//弹出层
	showDiv();
	
	//扩展主层的宽和高
	expandDiv();
	}

/* 带参函数 */
//必选  szaddObj：隐藏DIV的值 如"obj"，
//可选  szTouMingDu背景层的透明度值小 越透明 如 "30"，
//可选  szSuDu弹出div的速度 值越小速度越大 如 "10"
//可选  szZhenBiColor 透明层的颜色 如"#000000"
//可选  szDIVColor 弹出div的颜色 如"White"；
function showMyDiv(cuShowContentDiv) {

	if (cuShowContentDiv != null && cuShowContentDiv != "")
		dfShowContentDiv = cuShowContentDiv;
		
	//隐藏覆盖层
	document.getElementById(dfCoverDiv).style.visibility = "hidden";
	
	//弹出背景层
	showBgDiv();
	
	//弹出层
	showDiv();
	
	//扩展主层的宽和高
	expandDiv();
}

//弹出背景层
function showBgDiv() {
	
	var _showBgDiv = document.getElementById(dfShowBgDiv);
	
	_showBgDiv.style.position = "absolute";
	
	_showBgDiv.style.overflow = "hidden";

	_showBgDiv.style.border = "none";

	_showBgDiv.style.display = "block";

	_showBgDiv.style.top = "0px";

	_showBgDiv.style.left = "0px";

	_showBgDiv.style.background = dfShowBgDivBgColor;

	//_showBgDiv.style.zIndex = 9998;
	//document.body.scrollHeight

	_showBgDiv.style.width = iWidth+"px";

	_showBgDiv.style.height =iHeight+"px" ;

	_showBgDiv.style.filter = "alpha(opacity=" + dfShowBgDivAlpha + ")";

}

//弹出层
function showDiv() {
	
	var _showDiv = document.getElementById(dfShowDiv);

	_showDiv.style.position = "absolute";

	_showDiv.style.border = "none";

	_showDiv.style.display = "block";

	_showDiv.style.background = dfShowDivBgColor;

	_showDiv.style.top = (document.documentElement.scrollTop + window.screen.height/ 2 - 100) +"px";
	
	_showDiv.style.left = (window.screen.width / 2)+"px";
	
	_showDiv.style.width = "50px";

	_showDiv.style.height = "20px";

	document.getElementById(dfShowContentDiv).style.display = "block";

}

//扩展层的宽和高
function expandDiv() {

	var _showDiv = document.getElementById(dfShowDiv);

	var width = document.getElementById(dfShowDiv).offsetWidth ;

	var height = document.getElementById(dfShowDiv).offsetHeight ;

	var left = document.getElementById(dfShowDiv).offsetLeft ;

	var top = document.getElementById(dfShowDiv).offsetTop;

	_showDiv.style.left = (left - 40)+"px";
	
	_showDiv.style.top = (top - dfShowDivHeight / dfShowDivWidth * 5 / 2 - 16)+"px";

	_showDiv.style.width = (width + 75 - 1)+"px";

	_showDiv.style.height = (height + dfShowDivHeight / dfShowDivWidth * 4 + 40)+"px";

	if (width < dfShowDivWidth) {

		setTimeout("expandDiv()", dfShowDivSpeed);
		
	} else {
		
		//加载隐藏的div
		var _showDiv = document.getElementById(dfShowDiv);
		
		_showDiv.style.height = height +"px";
		
		_showDiv.style.width = width +"px";
		
		_showDiv.style.position = "absolute";
		
		_showDiv.style.top = (top - 5)+"px";
		
		_showDiv.style.left = (left - 5)+"px";
		
		_showDiv.style.display = "";
	}
}
//关闭DIV
function Close() {

	var _showDiv = document.getElementById(dfShowDiv);
	document.getElementById(dfShowContentDiv).style.display = "none";

	dfFormIndex = 0;

	var h;

	var width = document.getElementById(dfShowDiv).offsetWidth;

	var height = document.getElementById(dfShowDiv).offsetHeight;

	var left = document.getElementById(dfShowDiv).offsetLeft;

	var top = document.getElementById(dfShowDiv).offsetTop;

	_showDiv.style.left = (left + 10)+"px";

	_showDiv.style.top = (top + dfShowDivHeight / dfShowDivWidth * 5 / 2 + 35)+"px";

	_showDiv.style.width = (width - 20)+"px";

	_showDiv.style.height = (height - dfShowDivHeight / dfShowDivWidth * 5 - 1)+"px";

	if (window.parseFloat(_showDiv.style.width + 30) < 80) {
		
		var _showDiv = document.getElementById(dfShowDiv);
		
		var _showBgDiv = document.getElementById(dfShowBgDiv);
		_showDiv.style.display = "none";
		
		_showBgDiv.style.display = "none";
		
		window.clearTimeout(h);
		
		document.getElementById(dfCoverDiv).style.visibility = "visible"; 
	} else {
		
		h = setTimeout("Close()", dfShowDivSpeed);
	}
}
